package com.lr.excel.controller;

import com.lr.excel.service.ExcelOperateService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (ExcelData)表控制层
 *
 * @author makejava
 * @since 2024-06-13 22:16:01
 */
@RestController
@RequestMapping("excelData/")
public class ExcelOperateController {
    /**
     * 服务对象
     */
    @Resource
    private ExcelOperateService excelOperateService;


    /**
     * 单线程使用EasyExcel将Excel的数据导入到mysql
     * @return
     */
    @GetMapping("importDataFromExcelWithEasyExcel")
    public ResponseEntity<Boolean> importDataFromExcelWithEasyExcel() {
        excelOperateService.importDataFromExcelWithEasyExcel();
        return ResponseEntity.ok(true);
    }

    /**
     * 多线程使用EasyExcel将Excel的数据导入到mysql
     * @return
     */
    @GetMapping("importDataFromExcelWithEasyExcelASync")
    public ResponseEntity<Boolean> importDataFromExcelWithEasyExcelASync() {
        excelOperateService.importDataFromExcelWithEasyExcelASync();
        return ResponseEntity.ok(true);
    }

    @GetMapping("exportDataToExcel")
    public ResponseEntity<Boolean> exportDataToExcel() {
        excelOperateService.exportDataToExcel();
        return ResponseEntity.ok(true);
    }



}

